#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
class Solution
{
public:
    int minSubArrayLen(int target, const vector<int>& nums)
    {
        int l = 0, r = 0, sum = 0, len = 999999;
        int n = nums.size();
        for (; r < n; r++)
        {
            sum += nums[r];
            while (sum >= target)
            {
                int ret = r - l + 1;
                if (ret < len) len = ret;
                sum -= nums[l++];
            }
        }
        return len == 999999 ? 0 : len;
    }
};
int main()
{
    Solution s;
    s.minSubArrayLen(7, { 2,3,1,2,4,3 });
    return 0;
}